class Friendship {
  int? id;
  int userId;
  int friendId;
  DateTime createdAt;

  Friendship({
    this.id,
    required this.userId,
    required this.friendId,
    required this.createdAt,
  });

  Map<String, dynamic> toMap() {
    return {
      'id': id,
      'userId': userId,
      'friendId': friendId,
      'createdAt': createdAt.millisecondsSinceEpoch,
    };
  }

  factory Friendship.fromMap(Map<String, dynamic> map) {
    return Friendship(
      id: map['id'],
      userId: map['userId'],
      friendId: map['friendId'],
      createdAt: DateTime.fromMillisecondsSinceEpoch(map['createdAt']),
    );
  }

  Friendship copyWith({
    int? id,
    int? userId,
    int? friendId,
    DateTime? createdAt,
  }) {
    return Friendship(
      id: id ?? this.id,
      userId: userId ?? this.userId,
      friendId: friendId ?? this.friendId,
      createdAt: createdAt ?? this.createdAt,
    );
  }
}
